import { View, Text, ITouchEvent } from '@tarojs/components';
import { ArrowDown } from '@nutui/icons-react-taro';
import styles from './style.scss';
import { ReactNode } from 'react';

type Props = {
  value?: any;
  placeholder?: any;
  onClick?: (e: ITouchEvent) => void;
  icon?: ReactNode;
};
export default ({ value, placeholder = '请选择', onClick, icon }: Props) => {
  return (
    <View className={styles.container} onClick={onClick}>
      <View className={styles.content}>
        {value ? (
          <Text className={styles.textContent}>{value}</Text>
        ) : (
          <Text className={styles.placeholder}>{placeholder}</Text>
        )}
      </View>
      {icon || <ArrowDown className={styles.downIcon} />}
    </View>
  );
};
